package org.easyframework.bad.core;

import java.io.IOException;
import java.io.InputStream;

public class ProcessStreamReader extends Thread {
	/**
	 * Stream being read
	 */

	private InputStream stream;

	/**
	 * The StringBuffer holding the captured output
	 */

	private StringBuffer captureBuffer;

	/**
	 * Constructor.
	 * 
	 * @param
	 */

	public ProcessStreamReader(StringBuffer captureBuffer, InputStream stream) {
		this.stream = stream;
		this.captureBuffer = captureBuffer;
		start();
	}

	/**
	 * Stream the data.
	 */

	public void run() {
		try {
			int nextChar;
			while ((nextChar = stream.read()) != -1) {
				captureBuffer.append((char) nextChar);
			}

			System.out.println(captureBuffer.toString());
		} catch (IOException ioe) {
		}
	}
}
